//
//  UITableView+EmptyData.m
//  SHShopping
//
//  Created by 坤鼎 on 2019/9/8.
//  Copyright © 2019 kunding. All rights reserved.
//

#import "UITableView+EmptyData.h"

@implementation UITableView (EmptyData)

//添加一个方法
- (void)tableViewDisplayWitMsg:(NSString *)message ifNecessaryForRowCount:(NSUInteger)rowCount image:(NSString *)imageStr {
    
    if (rowCount == 0) {
        if (IsNilString(imageStr)) {
            imageStr = @"noNet";
        }
        UIView *backgroundView = [[UIView alloc] initWithFrame:self.bounds];
        UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:ImageNamed(imageStr)];
        backgroundImageView.frame = CGRectMake((SCREEN_WIDTH - 144) / 2, 171 - kNavBarAndStatusBarHeight, 144, 119);
        [backgroundView addSubview:backgroundImageView];
        
        UILabel *lbState = [[UILabel alloc] initWithFrame:CGRectMake(0, GetViewYH(backgroundImageView) + 20, SCREEN_WIDTH, 20)];
        lbState.text = message;
        lbState.textAlignment = 1;
        lbState.textColor = [UIColor lightGrayColor];
        lbState.font = FONT(14);
        [backgroundView addSubview:lbState];
        
//        UIButton *reloadBtn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 110) / 2, GetViewYH(lbState) + 64, 110, 36)];
//        [reloadBtn setTitle:@"重新加载" forState:UIControlStateNormal];
//        [reloadBtn gradientViewColorArray:@[]];
//        [reloadBtn addTarget:self action:@selector(actionReload) forControlEvents:UIControlEventTouchUpInside];
//        [backgroundView addSubview:reloadBtn];
        
        self.backgroundView = backgroundView;
    } else {
        self.backgroundView = nil;
    }
}



@end
